<?php
  class tmcContactPluginActions extends sfActions
  {
    public function executeContact(sfWebRequest $request)
    {
      $this->form = new tmcContactForm();
      if ($request->isMethod('post')){
        $this->form->bind($request->getParameter($this->form->getName()));
        if ($this->form->isValid()){
          $this->object = $this->form->save();
          // e-mail
          $this->getMailer()->send(new tmcContactMailer($this->object));
          // redirect
          $this->getUser()->setFlash('object', $this->object);
          $this->redirect($this->generateUrl(sfConfig::get('app_tmcContactPlugin_redirect', 'tmc_contact_form'), true));
        }
      }
    }
  }
?>
